//
//  GoodTitlePriceCell.m
//  B2C
//
//  Created by xiaowu on 2017/7/31.
//  Copyright © 2017年 lixiaolong. All rights reserved.
//

#import "GoodTitlePriceCell.h"

@implementation GoodTitlePriceCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    self.titleLabel.font = TextNormalFont16;
    self.titleLabel.textColor = [UIColor blackTextColor];
    
    self.subTitleLabel.font = TextNormalFont14;
    self.subTitleLabel.textColor = [UIColor gray66Color];
    
    self.priceLabel.font = TextNormalFontSize(20);
    self.priceLabel.textColor = [UIColor orangePriceColor];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setValueForCell:(NSString *)title subTitle:(NSString *)subTitle price:(NSString *)price oldPrice:(NSString *)oldPrice {

    self.titleLabel.text = title;
    self.subTitleLabel.text = subTitle;
    self.priceLabel.text = [NSString stringWithFormat:@"¥%@", price];
    self.oldPriceTitleLabel.text = @"原价";
    self.oldPriceTitleLabel.font = TextNormalFont12;
    self.oldPriceTitleLabel.textColor = [UIColor gray66Color];
    
    if (oldPrice.length > 0) {
        NSString *oldStr = [NSString stringWithFormat:@" ¥%@ ",oldPrice];
        
        NSRange range = NSMakeRange(0, oldStr.length);
        
        NSMutableAttributedString *attributeStr = [[NSMutableAttributedString alloc] initWithString:oldStr];
        [attributeStr addAttribute:NSFontAttributeName value:TextNormalFont12 range:range];
        
        [attributeStr addAttribute:NSForegroundColorAttributeName value:[UIColor gray66Color] range:range];
        [attributeStr addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlineStyleSingle|NSUnderlinePatternSolid) range:range];

        self.oldPriceLabel.attributedText = attributeStr;
    }
    

}

@end
